<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<!-- Casting SPELs in Lisp - Emacs Lisp Edition, a Comic Book
     Written by Conrad Barski, M.D., http://lisperati.com
     Edited by James A. Webb, http://uberkode.com -->

<head>

  <title>Casting SPELs in Lisp (25)</title>
  <meta http-equiv="content-type" content="text/html;charset=utf-8" />
  <meta http-equiv="Content-Style-Type" content="text/css" />
  <meta name="author" content="James A. Webb" />
  <meta name="date" content="2007-09-16T00:00:00+00:00" />
  <meta name="keywords" content="Emacs, Lisp" />

</head>

<body>

<center>

<table cellspacing="10" width="500">
  <tr>
    <td bgcolor="#AAFFAA" height="50" align="center">
        <b>Creating Special Actions in Our Game</b>
    </td>
  </tr>
  <tr>
    <td>
      We have only one more thing to do now and our game will be
      complete: Add some special actions that the player has to do
      to win in the game. The first command will let the player weld
      the chain to the bucket in the attic:
    </td>
  </tr>
  <tr>
    <td>
<pre style="font-weight: bolder; color: darkblue">
  (setq chain-welded nil)

  (defun weld (subject object)
    (cond ((and (eq location 'attic)
                (eq subject 'chain)
                (eq object 'bucket)
                (have 'chain)
                (have 'bucket)
                (not chain-welded))
	   (setq chain-welded 't)
           '(the chain is now securely welded to the bucket -))
          (t '(you cannot weld like that -))))
</pre>
    </td>
  </tr>
  <tr>
    <td>
      So first we created a new global variable that lets us tell
      whether we've done this action already. Next, we create a
      <tt>weld</tt> function that makes sure all the right conditions
      are in place for welding and lets us weld.
    </td>
  </tr>
  <tr>
    <td align ="center">
      <img src="../images/weld-chain-to-bucket.jpg"
        width="400" 
        height="403" 
        alt="Welding the chain to the bucket." />
    </td>
  </tr>
  <tr>
    <td align="center">
      &lt;&lt; <a href="casting-spels-emacs-1.html">begin</a>
      &lt; <a href="casting-spels-emacs-24.html">previous</a> - 
      <a href="casting-spels-emacs-26.html">next</a> &gt;
      <a href="casting-spels-emacs-35.html" >end</a> &gt;&gt;
    </td>
  </tr>
</table>

</center>

</body>

</html>